#include "stdafx.h"
#include <csetjmp>
class Rainbow
{
public:
  Rainbow(){cout<<"Rainbow"<<endl;}
  ~Rainbow(){cout<<"~Rainbow"<<endl;}

};
jmp_buf NonlocalKansas;
void NonlocalOz()
{
  Rainbow rb;
  for(int i=0;i<3;i++)
    cout<<"There is no place like home"<<endl;
  //47 will be used as return value when longjmp jmp to the setjump(NonlocalKansas)
  longjmp(NonlocalKansas,47);
}
void NonlocalExec()
{
  if(setjmp(NonlocalKansas)==0){
    cout<<"tornado,witch,munchkins..."<<endl;
    NonlocalOz();
  }else{
    cout<<"Auntie Em!"
      <<"I had the strangest dream..."
      <<endl;
  }
}
